/*
 * Id: $Id$
 *
 * Copyright (c) Critical Software S.A., All Rights Reserved.
 * (www.criticalsoftware.com)
 *
 * This software is the proprietary information of Critical Software S.A.
 * Use is subject to license terms.
 *
 * Last changed on : $Date$
 * Last changed by : $Author$
 */
package com.m2rt.queuenumber.mvc.impl;


import com.m2rt.queuenumber.domain.entities.Office;
import com.m2rt.queuenumber.service.OfficeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Description.
 *
 * @author :    Marco Ribeiro
 * @version :   $Rev$
 */

@Controller
@RequestMapping("/offices")
public class OfficeControllerImpl {

    @Autowired
    private OfficeService _service;


    @RequestMapping(value = "", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public List<Office> findStations(
            @RequestParam
            String name) {
        return _service.findOfficesByName(name);
    }

    @RequestMapping(value = "", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public Office create(
            @RequestBody
            Office office) {
        return _service.createOffice(office);
    }
}